<template>
  <div class="container">
    <div class="panol">
      <div class="list">
        <div class="item"
             v-for="(item,index) in list"
             @click="changeView(index)"
             :key="index">
          <div class="pic">
            <img :src="item.image" alt="">
            <div :class="['bottomText',{tranClass:index===listIndex}]"><span>{{ item.title }}</span></div>
          </div>
          <div v-show="index===listIndex" class="active"></div>
        </div>
      </div>
    </div>
    <div class="groupsText">
      <div class="navList">
        <div class="navItem"
             v-for="(item,index) in navList"
             @click="navSwich(index)"
             :key="index">
          {{ item.title }}
          <span v-show="index===navIndex"></span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "navbar",
  data(){
    return{
      listIndex:0,
      navIndex:0,
      list:[
        {
          image:"https://t7.baidu.com/it/u=1819248061,230866778&fm=193&f=GIF",
          title:"卧室房间"
        },
        {
          image:"https://t7.baidu.com/it/u=1819248061,230866778&fm=193&f=GIF",
          title:"卧室房间"
        },
        {
          image:"https://t7.baidu.com/it/u=1819248061,230866778&fm=193&f=GIF",
          title:"卧室房间"
        },
        {
          image:"https://t7.baidu.com/it/u=1819248061,230866778&fm=193&f=GIF",
          title:"卧室房间"
        }
      ],
      navList:[
        {
          title:"设备结构"
        },
        {
          title:"典型操作"
        }
      ]
    }
  },
  methods:{
    changeView(index){
      this.listIndex = index;
    },
    navSwich(index){
      this.navIndex = index;
    }
  }
}
</script>

<style scoped lang="less">
.container{
  position: absolute;
  left: 0;
  bottom: 50px;
  width: 100%;
  color: #FFF;
  z-index: 4001;
}
.panol{
  width: 100%;
  height: 78px;
  background-color: rgba(0, 0, 0, 0.4);
}
.groupsText{
  width: 100%;
  height: 30px;
  background-color: rgba(0, 0, 0, 0.4);
  border-top: 0.5PX solid #FFFFFF;
}
.list{
  display: flex;
  flex-direction: row;
  justify-content: center;
  padding-top: 10px;
  box-sizing: border-box;
  .item{
    width: 60px;
    height: 60px;
    border-radius: 1px;
    border: 2PX solid #FFFFFF;
    margin-right: 10px;
    position: relative;
    .pic{
      width: 100%;
      height: 100%;
      position: relative;
    }
    img{
      display: block;
      width: 100%;
      height: 100%;
    }
    .bottomText{
      width: 100%;
      height: 14px;
      line-height: 14px;
      font-size: 12PX;
      background: rgba(0, 0, 0, 0.6);
      border-radius: 0px 0px 1px 1px;
      position: absolute;
      left: 0;
      bottom: 0;
      z-index: 10;
      overflow: hidden;
    }
    .tranClass{
      span{
        display: block;
        width: 100%;
        height: 100%;
        animation: marqueeTransform 4s linear infinite;
      }
    }
  }
  .active{
    border: 2PX solid #F7B500;
    width: 100%;
    height: 100%;
    position: absolute;
    top: -2PX;
    left: -2PX;
    z-index: 999;

  }
}
.navList{
  display: flex;
  flex-direction: row;
  justify-content: center;
  .navItem{
    width: 70px;
    height: 30px;
    line-height: 30px;
    font-size: 15px;
    color: #FFFFFF;
    text-shadow: 0px 2px 8px rgba(0, 0, 0, 0.4);
    position: relative;
    span{
      width: 70px;
      height: 1px;
      background-color: #F7B500;
      position: absolute;
      left: 0;
      bottom: 2px;
    }
  }
}
@keyframes marqueeTransform {
  0%{
    transform: translate(100%, 0);
  }
  10%{
    transform: translate(80%, 0);
  }
  20%{
    transform: translate(60%, 0);
  }
  30%{
    transform: translate(40%, 0);
  }
  40%{
    transform: translate(20%, 0);
  }
  50%{
    transform: translate(0, 0);
  }
  60%{
    transform: translate(-20%, 0);
  }
  70%{
    transform: translate(-40%, 0);
  }
  80%{
    transform: translate(-60%, 0);
  }
  90%{
    transform: translate(-80%, 0);
  }
  100%{
    transform: translate(-100%, 0);
  }
}
</style>